
# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo10
# Description:
# Author:       98745
# Date:         2019/3/7
#-------------------------------------------------------------------------------

import re
r=re.sub('bill','mike','bill is my son')
print(r)
r=re.subn('bill','mike','bill is my son')
print(r)
print(r[0])
print('替换总数：',r[1])
r=re.sub('([0-9])([a-z]+)',r'产品编码(\1-\2)','01-1abc,02-2xyz,03-9hgf')
print(r)
def fun():
    return r'产品编码(\1-\2)'
r=re.subn('([0-9])([a-z]+)',fun(),'01-1abc,02-2xyz,03-9hgf')
print(r)
print(r[0])
print('替换总数：',r[1])